<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
ini_set('memory_limit', '256M');

// Define a destination
$targetFolder = dirname(__FILE__) . '/../../../../uploads/message'; // Relative to the root

$verifyToken = md5('unique_salt' . $_POST['timestamp']);

if (!empty($_FILES) && $_POST['token'] == $verifyToken) {

	$targetPath = $targetFolder;
    
    $name = explode('.', $_FILES['Filedata']['name']);
    $name = $name[0].'_'.strtotime('now').'.'.end($name);
    $encodeFile = sha1($name);
    
    //$targetFile =  iconv('unicode','shift-jis'.'//TRANSLIT',$targetFile);
    //echo mb_detect_encoding($targetFile, "auto");
    
	$targetFile = rtrim($targetPath,'/') . '/' . $encodeFile;

    move_uploaded_file($_FILES['Filedata']['tmp_name'],$targetFile);
    echo $name;

}
?>